import { message } from 'ant-design-vue'
import { markRaw } from 'vue'
import nav from './nav.js'

export default () => {
  const isLocal = ['172.20.10.2', '172.20.10.4'].some(v => location.origin.indexOf(v) > -1)

  let ld = {}
  try { ld = JSON.parse(localStorage.ld) } catch {}

  const keyMap = markRaw({
    13: 'enter',
    27: 'esc',
    37: 'left',
    38: 'top',
    39: 'right',
    40: 'bottom',
    ...(() => {
      const map = {}
      for (let i = 65; i < 65 + 26; i++) {
        map[i] = String.fromCharCode(i).toLowerCase()
      }
      return map
    })()
  })

  const ua = navigator.userAgent

  return {
    is: {
      local: isLocal,
    },
    ua,
    ld,
    nav,
    router: {},
    keyMap,
    message,
  }
}